<template>
  <div>
    <section class="nav_title">
      <i><img src="../../img/i-left.png"></i>
      后台管理
    </section>

    <section class="info_box info_box_manage">
      <i><img src="../../img/i-head.png"></i>
      <div class="info_box_left">
        <h3>{{ this.platformName }}</h3>
        <span><em><img src="../../img/i-rank.png" width="15"></em>等级：{{ this.platformLevel }}</span>
        <span><em><img src="../../img/i-info-phone.png" width="9"></em>电话：{{ this.platformPhoneNum }}</span>
      </div>
    </section>

    <section class="manage_list">
      <li>
        <h3><em><img src="../../img/i-customer.png" width="15"></em>申请提交客户</h3>
        <div class="manage_list_box">
                <span>
                    <router-link to="ShareInfo">
                        <em>
                          <img src="../../img/i-manage-link.png" width="15">
                        </em>申请设备客户数
                        <i><img src="../../img/i-right.png"></i><strong>{{ this.platformCount }}人</strong>
                    </router-link>
                </span>
        </div>
        <div class="f_cb"></div>
      </li>
      <li>
        <h3><em><img src="../../img/i-equitment.png" width="15"></em>安装设备用户</h3>
        <div class="manage_list_box">
                <span>
                    <router-link to="InstallShareInfo">
                        <em><img src="../../img/i-manage-customer.png" width="15"></em>分享安装客户数
                        <i><img src="../../img/i-right.png"></i><strong>{{ this.platformInstallCount }}人</strong>
                    </router-link>
                </span>
        </div>
        <div class="f_cb"></div>
      </li>
    </section>
  </div>
</template>
<script>
/* eslint-disable */

  export default {
    name: '',
    data() {
      return {
        openid: '',
        platformName: '',
        platformPhoneNum: '',
        platformLevel: '',
        platformCount: '',
        platformInstallCount: ''
      }
    },
    created() { //创建时运行
      //初始化数据
      this.initinfo();
    },
    methods: {
      initinfo: function () {
        //获取openid
        this.openid = this.util.getOpenid();
        console.log(localStorage.getItem('platformPhoneNum') + "  " + this.openid)


        //判断个人基本数据缓存是否有数据
        if (localStorage.getItem('platformPhoneNum') == null) {
          let params = {
            openid: this.openid
          }
          //查询代理商提交数据
          this.$axios.post(this.umcons.serviceAddress.GET_PLATFORM_INFO, params)
            .then((response) => {
              console.log(response.data.result != undefined)
              if (response.data.result != undefined) {
                console.log(response.data.result.agentsCount == undefined)
                this.platformName = response.data.result.platformName;
                this.platformPhoneNum = response.data.result.phoneNum;
                //平台商
                let isAgent = response.data.result.level;
                let agentsCount = response.data.result.agentsCount == undefined ? 0 : response.data.result.agentsCount;
                let platformCount = response.data.result.platformCount == undefined ? 0 : response.data.result.platformCount;
                this.platformInstallCount = response.data.result.platformInstallCount == undefined ? 0 : response.data.result.platformInstallCount;
                if (isAgent == 2) {
                  this.platformLevel = '运营商';
                  this.platformCount = platformCount;
                } else if (isAgent == 3) {
                  this.platformLevel = '代理商';
                  this.platformCount = agentsCount;
                } else if (isAgent == 1) {
                  console.log(isAgent)
                  this.platformLevel = '推广代理商';
                  this.platformCount = agentsCount;
                } else if (isAgent == 0) {
                  this.platformLevel = '普通申请者';
                  this.platformCount = agentsCount;
                }
                localStorage.setItem('openid', this.openid);
                localStorage.setItem('platformName', this.platformName);
                localStorage.setItem('platformPhoneNum', this.platformPhoneNum);
                localStorage.setItem('platformLevel', this.platformLevel);
                localStorage.setItem('platformCount', this.platformCount);
                localStorage.setItem('platformInstallCount',this.platformInstallCount);
              }else{
                  this.platformName = '暂无数据',
                  this.platformPhoneNum = '暂无数据',
                  this.platformLevel = '暂无数据',
                  this.platformCount = '0',
                  this.platformInstallCount = '0'
              }
            })
            .catch(function (error) {
              console.log(error)
            })


        } else {
          this.openid = localStorage.getItem('openid');
          this.platformName = localStorage.getItem('platformName');
          this.platformPhoneNum = localStorage.getItem('platformPhoneNum');
          this.platformLevel = localStorage.getItem('platformLevel');
          this.platformCount = localStorage.getItem('platformCount');
          this.platformInstallCount = localStorage.getItem("platformInstallCount");
        }
        //通过openid 查询用户个人信息，和设备信息

      }
    }
  }
</script>

<style scoped="scoped">
  @import url("../../css/common.css");
  @import url("../../css/style.css");

</style>
